home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-07 | 1.9 KB | 76 lines | [TEXT/MPS ] |
- (*
- CTBClose [abort] -- Close the current connection. If abort is present and non-empty then abort the
- connection.
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- pascal -w CTBClose.p
- link -m ENTRYPOINT -o HyperCommands -rt XCMD=2753 -sn Main=CTBClose ∂
- CTBClose.p.o "{MPW}"Libraries:interface.o "{MPW}"Libraries:Libraries:HyperXLib.o
-
- © Copyright 1990 by Apple Computer, Inc.
-
- Initial coding 2/90 by Harry R. Chesley.
- *)
-
- {$R-}
-
- {$S CTBClose } { Segment name must be the same as the command name. }
-
- unit DummyUnit;
-
- interface
-
- uses MemTypes, QuickDraw, OSIntf, ToolIntf, CTBUtils, FTIntf, CMIntf, TMIntf, CRMIntf, HyperXCmd;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- implementation
-
- procedure CTBClose(paramPtr: XCmdPtr); forward;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- begin
- CTBClose(paramPtr);
- end;
-
- procedure CTBClose(paramPtr: XCmdPtr);
-
- {$I CTBUtil.inc}
-
- var sizes: CMBufferSizes;
- status: CMStatFlags;
- ignore: OSErr;
-
- procedure Fail(errMsg: Str255); { set theResult and quit }
- begin
- paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
- exit(CTBClose);
- end;
-
- begin
- { Check the parameter count. }
- if paramPtr^.paramCount > 1 then Fail('Invalid parameter count');
-
- { Make sure the Comm Toolbox is here. }
- CTBReady;
-
- { Only close if there's something to close. }
- if Globals^^.connHand <> nil then
- if CMStatus(Globals^^.connHand,sizes,status) = noErr then
- begin
- { Only close if we're open or opening; if we're listening, then accept. }
- if Band(status,cmStatusOpen+cmStatusOpening) <> 0 then
- begin
- if ParmPresent(1) or (Band(status,cmStatusOpening) <> 0) then
- ignore := CMAbort(Globals^^.connHand);
- FailOSErr(CMClose(Globals^^.connHand,false,nil,3600,ParmPresent(1)));
- end
- else if Band(status,cmStatusListenPend+cmStatusIncomingCallPresent) <> 0 then
- FailOSErr(CMAccept(Globals^^.connHand,false));
- end;
- end;
-
- end.
-